Skip to content

chore: [WIP] experimental parallel kokoro system test#17608

Draft
chalmerlowe wants to merge 9 commits into
mainfrom
feat/parallel-kokoro-system-test
Draft

chore: [WIP] experimental parallel kokoro system test#17608
chalmerlowe wants to merge 9 commits into
mainfrom
feat/parallel-kokoro-system-test

Conversation

@chalmerlowe

@chalmerlowe chalmerlowe commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Warning

Something in this PR is off. Hold off on reviewing it.

Note

Results

Baseline: 2 hours 5 mins
With parallelization: 42 mins

@chalmerlowe chalmerlowe changed the title [WIP] chore/experimental parallel kokoro system test [WIP] chore: experimental parallel kokoro system test Jul 1, 2026
@chalmerlowe chalmerlowe changed the title [WIP] chore: experimental parallel kokoro system test chore: [WIP] experimental parallel kokoro system test Jul 1, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces parallel execution for system tests in .kokoro/system.sh with concurrency limits and log segregation, and isolates gcloud configurations per run using unique temporary directories. The feedback suggests robust cleanup of the temporary directories using shell traps to prevent leaks if commands fail under set -e, sanitizing package names used in directory creation, and refactoring the duplicate process reaping logic into a helper function to improve maintainability.

Comment thread .kokoro/system.sh
Comment thread .kokoro/system.sh Outdated
Comment thread .kokoro/system.sh Outdated
Comment thread .kokoro/system.sh Outdated
Comment thread .kokoro/system.sh Outdated
@chalmerlowe
chalmerlowe marked this pull request as ready for review July 16, 2026 18:43
@chalmerlowe
chalmerlowe requested review from a team as code owners July 16, 2026 18:43
@chalmerlowe
chalmerlowe requested review from sycai and removed request for a team July 16, 2026 18:43
@chalmerlowe chalmerlowe added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jul 16, 2026
@chalmerlowe

Copy link
Copy Markdown
Contributor Author

Applied Do Not Merge, simply because we will want to remove the throw-away comments just prior to merging.

@chalmerlowe chalmerlowe added kokoro:force-run Add this label to force Kokoro to re-run the tests. and removed kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Jul 16, 2026
@chalmerlowe chalmerlowe changed the title chore: [WIP] experimental parallel kokoro system test chore: experimental parallel kokoro system test Jul 17, 2026
@chalmerlowe chalmerlowe added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 17, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 17, 2026
@chalmerlowe
chalmerlowe marked this pull request as draft July 17, 2026 18:19
@chalmerlowe chalmerlowe changed the title chore: experimental parallel kokoro system test chore: [WIP] experimental parallel kokoro system test Jul 17, 2026
@chalmerlowe

Copy link
Copy Markdown
Contributor Author

Something in this PR is off. Hold off on reviewing it.

Comment thread .kokoro/system.sh

printf '%s\n' "${PACKAGES_TO_TEST[@]}" | xargs -P "$MAX_JOBS" -I {} bash -c 'run_package_test "{}" > "$LOG_DIR/{}.log" 2>&1 || touch "$LOG_DIR/{}.failed"'

reap_parallel_results || RETVAL=1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like right now, the main cloud-devrel/client-libraries/python/googleapis/google-cloud-python/presubmit/system target always returns 0. Is that intended? The individual sub-targets are still reporting properly, but it would probably be better to have the main target fail if any others do

Maybe the exit ${RETVAL} line was removed by mistake?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will ensure that last line gets in there.

Comment thread .kokoro/system.sh
local CLOUDSDK_CONFIG="${gcloud_config_dir}"

# 🪤 TRAP: Ensure cleanup of THIS specific temp dir on exit of this subshell
trap 'rm -rf "$gcloud_config_dir"' EXIT

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, is this required? I assumed the environment would just be destroyed after completion

Comment thread .kokoro/system.sh
export -f run_package_test
export system_test_script PROJECT_ROOT KOKORO_GFILE_DIR

printf '%s\n' "${PACKAGES_TO_TEST[@]}" | xargs -P "$MAX_JOBS" -I {} bash -c 'run_package_test "{}" > "$LOG_DIR/{}.log" 2>&1 || touch "$LOG_DIR/{}.failed"'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This is a pretty dense line. A comment explaining that this triggers run_package_test for each package, and writes to LOG_DIR would be helpful

Comment thread .kokoro/system.sh
MAX_JOBS=${MAX_JOBS:-4}

# Temporary directory for clean log segregation
LOG_DIR=$(mktemp -d -t test-logs-XXXXXX)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, the expectation is to write individual package logs to ${KOKORO_ARTIFACTS_DIR}/${pkg}/sponge_log.log".

In theory, this will persist the logs as an artifact, which would let us view logs for each individual target under the "Target Log" tab.

This doesn't work properly in the default BTX view. But if you click through to Sponge, it renders nicely there (invocation details > Sponge URL)

I don't think this really matters, but consider saving individual logs to that artifact directory any way, just in case BTX starts working for us some day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not merge Indicates a pull request not ready for merge, due to either quality or timing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants